<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>商品详情</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/node_modules/LobsterUIFrame/weui/css/weui.css" />
    <link rel="stylesheet" href="/node_modules/LobsterUIFrame/weui/css/weuix.css" />
    <script src="/node_modules/LobsterUIFrame/weui/js/zepto.min.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/zepto.weui.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/swipe.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/macy.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/php.js"></script>
    <script src="/lobstersdk/lobster.js"></script>
    <script src="/jslib/template-web.js"></script>
    <script src="../js/address.js"></script>
    <style>
        #slide1 {
            height: 300px;
        }

        .bottom {
            background-color: #F5F5F5;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            align-items: center;
            display: flex;
            padding: 10px 4px;
            z-index: 2;
        }

        .weui-btn {
            height: 40px;
            line-height: 40px;
        }

        .bottomimg {
            height: 30px;
            width: 30px;
        }

        .weui-navbar {
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            z-index: 99;
        }

        .price {
            color: #EE5555;
        }

        .price2 {
            margin-left: 20px;
            text-decoration: line-through;
        }

        .detailcont {
            padding: 0 15px;
        }

        .detailcont img {
            width: 100% !important;
            height: auto !important;
        }

        .detailcont p {
            width: 100% !important;
            height: auto !important;
        }

        .detailcont span {
            width: 100% !important;
            height: auto !important;
        }

        .detailcont video {
            width: 100% !important;
            height: auto !important;
        }

        .index_body {
            overflow-y: hidden;
            /*为了兼容普通PC的浏览器*/
            height: 100%;
            position: fixed;
        }

        .weui-label-list .label {
            line-height: 2em;
            height: 2em;
        }
    </style>
</head>

<body ontouchstart>
    <div class="weui-tab" id="t1" style="height:44px;">
        <div class="weui-navbar">
            <div class="weui-navbar__item">商品</div>
            <div class="weui-navbar__item">详情</div>
            <div class="weui-navbar__item">评论</div>
        </div>
    </div> 
    <div class="slide" id="slide1">

    </div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <span class="price" id="price"></span><span id="price2" class="price2"></span>
            </div>
            <div class="weui-cell__ft" id="yuexiao">月销</div>
        </div>
        <div class="weui-cell">
            <div id="goodsName" class="page-hd-title"></div>
        </div>
        <div class="weui-cell">
            <div id="goodsKey" class="page-hd-desc"></div>
        </div>
        <div style="height:10px;background-color: #F5F5F5;"></div>
        <div class="weui-cell weui-cell_access open-popup" id="tospec">
            <div class="weui-cell__bd">
                <span>规格</span><span id="spectxt">请选择规格</span>
            </div>
            <div class="weui-cell__ft"></div>
        </div>
        <div class="weui-cell weui-cell_access" id="toaddress">
            <div class="weui-cell__bd">
                <span>送至</span><span id="addresstxt">xx省xx市xx区xxxxxx</span>
            </div>
            <div class="weui-cell__ft"></div>
        </div>
        <div style="height:10px;background-color: #F5F5F5;"></div>
        <div id="evaluatediv" class="weui-cell weui-cell_access">
            <div class="weui-cell__bd">
                <span>用户评价</span>
            </div>
            <div class="weui-cell__ft" id="evaluatecount">0条评价</div>
        </div>
        <div class="weui-panel__bd" id="evaluatelist">

        </div>
        <div style="height:10px;background-color: #F5F5F5;"></div>
    </div>
    <div class="detailcont" id="detailcontdiv"></div>
    <div style="height:100px;"></div>
    <div class="bottom">
        <div style="flex:1;text-align: center;" id="tomall"><img class="bottomimg" src="../images/mall2.png">
            <div style="font-size:12px;">商城</div>
        </div>
        <div style="flex:1;text-align: center;position: relative;" id="tocart"><img class="bottomimg"
                src="../images/cart.png">
            <div style="font-size:12px;">购物车</div>
            <span class="weui-badge" style="position: absolute;top: -.4em;right: 1.6em;display:none;"></span>
        </div>
        <div style="flex:3;text-align:right;">
            <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary" style="border-radius: 0;" id="addcart"></i>加入购物车</a>
            <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary" style="border-radius: 0;" id="togou"></i>立即购买</a>
        </div>
    </div>
    <div id="half" class='weui-popup__container popup-bottom'>
        <div class="weui-popup__overlay"></div>
        <div class="weui-popup__modal">
            <div class="toolbar">
                <div class="toolbar-inner">
                    <a href="javascript:;" class="picker-button close-popup">关闭</a>
                    <h1 class="title">规格</h1>
                </div>
            </div>
            <div class="modal-content" id="modalcontent">
            </div>
        </div>
    </div>

    <div id="half2" class='weui-popup__container popup-bottom'>
        <div class="weui-popup__overlay"></div>
        <div class="weui-popup__modal">
            <div class="toolbar">
                <div class="toolbar-inner">
                    <a href="javascript:;" class="picker-button close-popup">关闭</a>
                    <h1 class="title">选择地址</h1>
                </div>
            </div>
            <div class="modal-content">
                <div class="weui-panel__bd" id="addresslist">
                </div>
            </div>
        </div>
    </div>
</body>

</html>
<script type="text/template" id="bannertemp">
    <ul>
        {{each list item}}
        <li>
            <a href="javascript:;">
                <img src='{{item}}' alt="">
            </a> 
        </li>
         {{/each}}
    </ul>
    <div class="dot">
        {{each list item}}
        <span></span> 
        {{/each}}
    </div>
</script>
<script type="text/template" id="evaluatetemp">
    {{each list item}}
    <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
        <div class="weui-media-box__hd">
            <img class="weui-media-box__thumb" src="{{item.UserImg}}" alt="">
        </div>
        <div class="weui-media-box__bd">
            <h4 class="weui-media-box__title">{{item.UserName}}</h4>
            <p class="weui-media-box__desc">{{(item.EvaluateTime||"").substring(0,19)}} {{item.SpecName}}</p>
            <div id="ss" class="f-green"> {{item.Startxt}}</div>
            <div class="weui-media-box__desc">{{item.Cont}}</div>
        </div>
    </a>
    {{/each}}
</script>
<script type="text/template" id="modaltemp">
        <div class="weui-panel__bd">
            <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
                <div class="weui-media-box__hd">
                    <img class="weui-media-box__thumb" src="{{selSpecObj.GoodsSpecImg}}" alt="">
                </div>
                <div class="weui-media-box__bd">
                    <h4 class="weui-media-box__title"><span class="price">{{selSpecObj.GoodsRetailPrice}}</span>
                        <span class="price2">{{selSpecObj.GoodsMarketPrice}}</span></h4>
                    <p class="weui-media-box__desc">请选择：<span>{{selSpecObj.SpecName||"规格"}}</span></p>
                    <p class="weui-media-box__desc">数量：<span>{{selSpecObj.num}}</span></p>
                </div>
            </a>
        </div>
        {{each speclist item idx}}
        <h4 class="weui-label-list weui-media-box__title">{{item.SpecName}}</h4>
        <div class="weui-label-list">
            {{each item.list item2 idx2}}
            {{if(item2.selected)}}
            <label class="label f-white bg-green specitem" data-idx={{idx}} data-idx2={{idx2}}>{{item2.SpecItemName}}</label>
            {{else}}
            <label class="label f-gray b-gray specitem"  data-idx={{idx}} data-idx2={{idx2}}>{{item2.SpecItemName}}</label>
            {{/if}}
            {{/each}} 
        </div>
        {{/each}} 
        <div class="weui-cell">
            <div class="weui-cell__hd"></div>
            <div class="weui-cell__bd">
                <p>数量</p>
            </div>
            <div class="weui-cell__ft">
                <div class="weui-count">
                    <a class="weui-count__btn weui-count__decrease"></a>
                    <input class="weui-count__number" type="number" value="{{selSpecObj.num}}" />
                    <a class="weui-count__btn weui-count__increase"></a>
                </div>
            </div>
        </div> 
        <div style="text-align: center;" style="position:relative;">
            {{if(selSpecObj.SpecDetailId == 0 || selSpecObj.GoodsStock <= 0)}}
            <a style="width: 40%;" href="javascript:;"
                class="weui-btn weui-btn_mini weui-btn_disabled weui-btn_default"></i>加入购物车</a>
            <a style="width: 40%;" href="javascript:;"
                class="weui-btn weui-btn_mini weui-btn_disabled weui-btn_default"></i>立即购买</a>
            {{else}}
            <a style="width: 40%;" href="javascript:;"
            class="weui-btn weui-btn_mini weui-btn_primary" id="addcart"></i>加入购物车</a>
            <a style="width: 40%;" href="javascript:;"
            class="weui-btn weui-btn_mini weui-btn_primary" id="tosettle"></i>立即购买</a>
            {{/if}}
        </div> 
</script>



<script>
    $.fn.scrollT = function (options) {
        var defaults = {
            toTop: 0,    //滚动目标位置
            durTime: 500,  //过渡动画时间
            delay: 30,     //定时器时间
            callback: null   //回调函数
        };
        var opts = $.extend(defaults, options),
            timer = null,
            _this = this,
            curTop = _this.scrollTop(),//滚动条当前的位置
            subTop = opts.toTop - curTop,    //滚动条目标位置和当前位置的差值
            index = 0,
            dur = Math.round(opts.durTime / opts.delay),
            smoothScroll = function (t) {
                index++;
                var per = Math.round(subTop / dur);
                if (index >= dur) {
                    _this.scrollTop(t);
                    window.clearInterval(timer);
                    if (opts.callback && typeof opts.callback == 'function') {
                        opts.callback();
                    }
                    return;
                } else {
                    _this.scrollTop(curTop + index * per);
                }
            };
        timer = window.setInterval(function () {
            smoothScroll(opts.toTop);
        }, opts.delay);
        return _this;
    };
    lobsterh5.main({
        data: {
            goodsId: 0,
            bannerList: [],
            goodsObj: {},
            speclist: [],
            specdetaillist: [],
            evaluatelist: [],
            evaluatecount: 0,
            selSpecObj: {
                SpecDetailId: 0,
                num: 1,
                GoodsStock: 1,
            },
            cartNum: 0,
            address: {},
            addressList: [],
        },
        //初始化页面
        pageload: function () {
            this.initevent();
            this.data.goodsId = lobsterh5.GetUrlParam("goodsid");
            if (localStorage.getItem("address")) {
                this.data.address = JSON.parse(localStorage.getItem("address")) || {};
                if (this.data.address.AreaInfo)
                    $("#addresstxt").text(this.data.address.AreaInfo);
            }
            this.getalldata();
        },
        //初始化事件
        initevent: function () {
            var self = this;
            $('#t1').tab({
                defaultIndex: 0,
                activeClass: 'tab-green',
                onToggle: function (index) {
                    var _id = $("#t1");
                    if (index == 0)
                        _id = $("#t1");
                    else if (index == 1)
                        _id = $("#detailcontdiv");
                    else if (index == 2)
                        _id = $("#evaluatediv");
                    var top = _id.offset().top;
                    window.scrollTo(0, top-44);

                    // $("body").scrollT({ toTop: top, durTime: 300 });
                }
            })

            $(document).on("open", ".weui-popup__modal", function () {
                self.stop();
            }).on("close", ".weui-popup__modal", function () {
                self.move();
            });
            $("#modalcontent").on("click", '.weui-count__decrease', function (e) {
                self.changenum(0);
                var $input = $(e.currentTarget).parent().find('.weui-count__number');
                $input.val(self.data.selSpecObj.num);

            })
            $("#modalcontent").on("click", '.weui-count__increase', function (e) {
                self.changenum(1);
                var $input = $(e.currentTarget).parent().find('.weui-count__number');
                $input.val(self.data.selSpecObj.num);

            })
            $("#addcart,#togou,#tospec").click(function () {
                $("#half").popup();//打开 

            })
            $("#toaddress").click(function () {
                $("#half2").popup();//打开 
            })
            $("#tomall").click(function () {
                location.href = "../index.html";
            })
            $("#tocart").click(function () {
                location.href = "../cart/index.html";
            })
            $("#modalcontent").on("click", ".specitem", function () {
                var idx = $(this).data("idx");
                var idx2 = $(this).data("idx2");
                self.data.speclist[idx].list.forEach(a => {
                    a.selected = false;
                })
                self.data.speclist[idx].list[idx2].selected = true;
                var arr = [];
                self.data.speclist.forEach(a => {
                    var filter = a.list.filter(b => {
                        return b.selected
                    });
                    if (filter != null && filter.length > 0)
                        arr.push(filter[0]);
                })
                if (arr.length == self.data.speclist.length) {
                    var specfilter = self.data.specdetaillist.filter(a => {
                        var speccom = arr.map(n => n.SpecId).sort((a1, a2) => {
                            return a1 - a2;
                        }).join("_");
                        var sepcitemcom = arr.map(n => n.SpecItemId).sort((a1, a2) => {
                            return a1 - a2;
                        }).join("_")
                        return a.SpecCom == speccom && a.SpecItemCom == sepcitemcom;
                    })
                    self.data.selSpecObj.num = 1;
                    if (specfilter != null && specfilter.length > 0) {
                        self.data.selSpecObj.SpecDetailId = specfilter[0].GoodsSpecDetailId;
                        self.data.selSpecObj.SpecName = arr.map(n => n.SpecItemName).join(";");
                        self.data.selSpecObj.GoodsSpecImg = specfilter[0].GoodsSpecImg;
                        self.data.selSpecObj.GoodsRetailPrice = specfilter[0].GoodsRetailPrice;
                        self.data.selSpecObj.GoodsMarketPrice = specfilter[0].GoodsMarketPrice;
                        self.data.selSpecObj.GoodsStock = specfilter[0].GoodsStock;
                        if (self.data.selSpecObj.GoodsStock <= 0)
                            $.toast("商品数量为0", 'text');
                    } else {
                        self.data.selSpecObj.SpecDetailId = 0;
                        $.toast("无此规格", 'text');
                    }
                }
                self.initmodal();
                $("#spectxt").text(self.data.selSpecObj.SpecName);
            })

            $("#modalcontent").on("click", '#addcart', function (e) {
                var selSpecObj = self.data.selSpecObj;
                if (selSpecObj.SpecDetailId == 0 || selSpecObj.GoodsStock <= 0) {
                    return;
                }
                $.showLoading("加入购物车...")
                lobsterh5.POST("/lowcode/APP20200616102057595/shop/?fun=mall.addcart", {
                    GoodsId: self.data.goodsObj.GoodsId,
                    Num: selSpecObj.num,
                    SpecName: selSpecObj.SpecName,
                    SpecDetailId: selSpecObj.SpecDetailId,
                    UserId: localStorage.getItem("userId")
                }).then(res => {
                    $.hideLoading();
                    self.getcartcount().then(res => {
                        if (res.cartcount > 0)
                            $(".weui-badge").show().text(res.cartcount)
                    })
                    $.toast("加入购物车成功");
                    $.closePopup();
                }).catch(res => {
                    $.toast(res.msg, 'text');
                })
            })
            $("#modalcontent").on("click", '#tosettle', function (e) {
                var selSpecObj = self.data.selSpecObj;
                var goodsObj = self.data.goodsObj;
                if (selSpecObj.SpecDetailId == 0 || selSpecObj.GoodsStock <= 0) {
                    $.toast("请选择商品属性", 'text');
                    return;
                }
                if (selSpecObj.num == 0) {
                    $.toast("数量不能为0", 'text');
                    return;
                }
                var goods = [{
                    ShopId: goodsObj.ShopId,
                    ShopName: goodsObj.ShopName,
                    GoodsId: goodsObj.GoodsId,
                    GoodsName: goodsObj.GoodsName,
                    GoodsPrice: selSpecObj.GoodsRetailPrice,
                    GoodsNum: selSpecObj.num,
                    SpecName: selSpecObj.SpecName,
                    SpecDetailId: selSpecObj.SpecDetailId,
                    SpecImg: selSpecObj.GoodsSpecImg
                }]
                location.href = "../settle/index.html?address=" + encodeURIComponent(JSON.stringify(self.data.address))
                    + "&goods=" + encodeURIComponent(JSON.stringify(goods));
            })
            $("#evaluatecount").click(function () {
                location.href = "allevaluate.html?goodsId=" + self.data.goodsObj.GoodsId
            })

        },
        changenum(type) {
            var selSpecObj = this.data.selSpecObj;
            if (selSpecObj.SpecDetailId == 0 || selSpecObj.GoodsStock <= 0)
                return;
            if (type == 0) {
                selSpecObj.num--;
                if (selSpecObj.num < 1) {
                    selSpecObj.num = 1
                    $.toast("数量低于范围~", 'text');
                }
            } else {
                selSpecObj.num++;
                if (selSpecObj.num > selSpecObj.GoodsStock) {
                    selSpecObj.num = selSpecObj.GoodsStock < 0 ? 1 : selSpecObj.GoodsStock
                    $.toast("数量超出范围~", 'text');
                }
            }
            this.initmodal();

        },
        //初始化banner图
        initbanner: function () {
            var html = template("bannertemp", { list: this.data.bannerList, });
            $("#slide1").html(html);
            $('#slide1').swipeSlide({
                autoSwipe: true,//自动切换默认是
                speed: 3000,//速度默认4000
                continuousScroll: true,//默认否
                transitionType: 'cubic-bezier(0.22, 0.69, 0.72, 0.88)',//过渡动画linear/ease/ease-in/ease-out/ease-in-out/cubic-bezier
                lazyLoad: true,//懒加载默认否
                firstCallback: function (i, sum, me) {
                    me.find('.dot').children().first().addClass('cur');
                },
                callback: function (i, sum, me) {
                    me.find('.dot').children().eq(i).addClass('cur').siblings().removeClass('cur');
                }
            });
        },
        initevalute: function () {
            $("#evaluatecount").text(this.data.evaluatecount + "条评论");
            this.data.evaluatelist.forEach(a => {
                a.Startxt = '★★★★★☆☆☆☆☆'.substring(5 - a.Star, 10 - a.Star);
            })
            var html = template("evaluatetemp", { list: this.data.evaluatelist, });
            $("#evaluatelist").html(html);
        },
        initgoods: function () {
            var goodsObj = this.data.goodsObj;
            $("#price").text(goodsObj.GoodsRetailPrice);
            $("#price2").text(goodsObj.GoodsMarketPrice);
            $("#yuexiao").text("月销 " + (goodsObj.MonthLatestSalesVolume > goodsObj.FakeMonthLatestSalesVolume ?
                goodsObj.MonthLatestSalesVolume : goodsObj.FakeMonthLatestSalesVolume))
            $("#goodsName").text(goodsObj.GoodsName);
            $("#goodsKey").text(goodsObj.GoodsKey);
            $(".detailcont").html(goodsObj.GoodsDescribe);
        },
        initmodal: function () {
            var html = template("modaltemp", { selSpecObj: this.data.selSpecObj, speclist: this.data.speclist });
            $("#modalcontent").html(html);

        },
        getalldata: function () {
            var self = this;
            Promise.all([self.getgoodsdetail(), self.getevaluatelist(), self.getspeclist(), self.getaddresslist(), self.getcartcount()]).then(res => {
                self.data.goodsObj = res[0].goodsdetail;
                self.data.goodsObj.MonthLatestSalesVolume = self.data.goodsObj.MonthLatestSalesVolume || 0;
                self.data.goodsObj.FakeMonthLatestSalesVolume = self.data.goodsObj.FakeMonthLatestSalesVolume || 0;
                self.data.selSpecObj.GoodsSpecImg = self.data.goodsObj.GoodsMainPic;
                self.data.selSpecObj.GoodsRetailPrice = self.data.goodsObj.GoodsRetailPrice;
                self.data.selSpecObj.GoodsMarketPrice = self.data.goodsObj.GoodsMarketPrice;
                self.data.bannerList = (self.data.goodsObj.GoodsBanner || "").split(",");
                self.data.evaluatelist = res[1].data;
                self.data.evaluatecount = res[1].count;
                self.data.specdetaillist = res[2].specdetaillist;
                self.data.speclist = self.groupArr(res[2].speclist, "SpecId");
                self.initgoods();
                self.initbanner();
                self.initevalute();
                self.initmodal();
                // self.initaddress();
                $("#addresslist").lobsteraddress({
                    addresslist: self.data.addressList, selectaddress: function (data) {
                        $.closePopup();
                        localStorage.setItem("address", JSON.stringify(data));
                        $("#addresstxt").text(data.AreaInfo);
                        self.data.address = data;
                    }
                });
                if (res[4].cartcount > 0)
                    $(".weui-badge").show().text(res[4].cartcount)
            })
        },
        stop() {
            $('body').on('touchmove', function (event) {
                event.preventDefault();
            });
            if (window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger') {
                $('body').addClass('index_body');//添加禁止滚动的样式
            }
        },
        move() {
            $('body').off('touchmove');
            document.removeEventListener("touchmove", function (e) { e.preventDefault(); }, { passive: false });
            if (window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger') {
                $('body').removeClass('index_body');//添加禁止滚动的样式
            }
        },
        groupArr(list, field) {
            var fieldList = [],
                att = [];
            list.map((e) => {
                fieldList.push(e[field])
            })
            //数组去重
            fieldList = fieldList.filter((e, i, self) => {
                return self.indexOf(e) == i
            })
            for (var j = 0; j < fieldList.length; j++) {
                //过滤出匹配到的数据
                var arr = list.filter((e) => {
                    return e.SpecId == fieldList[j];
                })
                att.push({
                    SpecId: arr[0].SpecId,
                    SpecName: arr[0].SpecName,
                    list: arr
                })
            }
            return att;
        },
        getgoodsdetail: function () {
            var self = this;
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/lowcode/APP20200616102057595/shop/?fun=mall.getgoodsdetail&workid=" + lobsterh5.GetWorkId(), {
                    goodsId: self.data.goodsId
                }).then(res => {
                    resolve(res);
                }).catch(res => {
                    $.toast(res.msg, 'text');
                    reject(res);
                })
            })
        },
        getevaluatelist: function () {
            var self = this;
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/lowcode/APP20200616102057595/shop/?fun=mall.getevaluatelist&workid=" + lobsterh5.GetWorkId(), {
                    page: 1, limit: 3,
                    goodsId: self.data.goodsId
                }).then(res => {
                    resolve(res);
                }).catch(res => {
                    $.toast(res.msg, 'text');
                    reject(res);
                })
            })
        },
        getspeclist: function () {
            var self = this;
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/lowcode/APP20200616102057595/shop/?fun=mall.getspeclist&workid=" + lobsterh5.GetWorkId(), {
                    goodsId: self.data.goodsId
                }).then(res => {
                    resolve(res);
                }).catch(res => {
                    $.toast(res.msg, 'text');
                    reject(res);
                })
            })
        },
        getaddresslist() {
            var self = this;
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/sso/v1/patient/GetAddressList", {}).then(res => {
                    var addressList = res.addressList;
                    //地址数据集添加显示字段
                    if (addressList && addressList.length > 0) {
                        addressList.forEach((item, index) => {
                            //地址信息
                            var Province = item.Province ? item.Province : "";
                            var City = item.City ? item.City : "";
                            var District = item.District ? item.District : "";
                            item.AreaInfo = Province + City + District + item.Street; //地址信息
                            item.checked = item.IsDefault == 1 ? true : false; //是否为默认地址 
                        });
                        self.data.addressList = addressList;
                    } else {
                        self.data.addressList = [];
                    }
                    resolve();
                }).catch(res => {
                    $.toast(res.msg, 'text');
                    reject(res);
                })
            });
        },
        getcartcount() {
            var self = this;
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/lowcode/APP20200616102057595/shop/?fun=mall.getcartcount", {
                    userId: localStorage.getItem("userId")
                }).then(res => {
                    resolve(res);
                }).catch(res => {
                    $.toast(res.msg, 'text');
                    reject(res);
                })
            });
        },
        udpatecartnum(model) {
            var self = this;
            lobsterh5.POST("/lowcode/APP20200616102057595/shop/?fun=mall.updatecartnum", {
                CartId: model.CartId,
                Num: model.Num
            }).then(res => {

            }).catch(res => {
                $.toast(res.msg, 'text');

            })
        }
    })
</script>